'use strict';
module.exports = (app) => {
  const { STRING, INTEGER, TEXT } = app.Sequelize;
  const User = app.model.define('b_user', {
    id: {
      type: INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    token: {
      comment: '令牌',
      type: STRING,
    },
    phone: {
      comment: '手机号',
      type: STRING(11),
      unique: true,
      allowNull: false,
    },
    name: {
      comment: '用户名',
      type: STRING(32),
      allowNull: false,
    },
    password: {
      comment: '用户密码',
      type: STRING(255),
      allowNull: false,
    },
    avatar: {
      comment: '用户头像',
      type: TEXT,
      // defaultValue: "https://blog-1251395798.cos.ap-guangzhou.myqcloud.com/image/_1632800038512_bluej.png",
    },
    desc: {
      comment: '用户简介',
      type: STRING,
      defaultValue: '呢个人好懒，咩都冇留低',
      allowNull: true,
    },
    blogCount: {
      comment: '发布博客总数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
    followCount: {
      comment: '关注总数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
    fanCount: {
      comment: '粉丝总数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
    likeCount: {
      comment: '点赞总数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
    historyCount: {
      comment: '浏览总数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
    commentCount: {
      comment: '评论总数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
    replyCount: {
      comment: '被回复总数',
      type: INTEGER,
      defaultValue: 0,
      validate: { min: 0 },
    },
    projectId: {
      comment: '所属项目id',
      type: INTEGER,
      allowNull: false,
    },
    status: {
      comment: '用户状态',
      type: INTEGER,
      defaultValue: 1,
      allowNull: false,
    },
    token_out_of_date: {
      type: STRING,
      comment: 'token 过期时间， 时间戳',
    },
    last_ip: {
      type: STRING,
      comment: '上次登陆ip地址',
      allowNull: true,
    },
  });

  // (async () => {
  //   await User.sync({ alter: true });
  //   // 这是代码
  // })();

  return User;
};
